

package com.hazelcast.test;

public class DefaultTaskProgress implements TaskProgress {
    private final long timestamp = System.currentTimeMillis();
    private final int total;
    private final int done;
    private final double progress;
    private final boolean completed;

    public DefaultTaskProgress(int total, int done) {
        this.total = total;
        this.done = done;
        this.progress = ((double) done) / total;
        this.completed = total == done;
    }

    @Override
    public boolean isCompleted() {
        return completed;
    }

    @Override
    public double progress() {
        return progress;
    }

    @Override
    public long timestamp() {
        return timestamp;
    }

    @Override
    public String getProgressString() {
        return String.format("%d/%d=%.2f%%", done, total, progress * 100);
    }
}
